$(function () {
    let int = setInterval(clock,1000)
    var cookie = {};
    var cookies = document.cookie.replace(/[ ]/g,'').split(';')
    cookie = {};
    $.each(cookies,function (index,item) {
        var kv = item.split('=');
        cookie[kv[0]] = kv[1];
    })
    var userId = cookie.userId;
    function clock() {
        cookie = {};
        cookies = document.cookie.replace(/[ ]/g,'').split(';')
        $.each(cookies,function (index,item) {
            var kv = item.split('=');
            cookie[kv[0]] = kv[1];
        })
        var newUserId = cookie.userId;
        if (userId && userId !== newUserId){
            layer.alert("登陆信息已变更，需关闭当前窗口后重新打开!",{
                cancel: function(index){
                    layer.close(index)
                    clock();
                    return false;
                }
            },function (index) {
                window.close();
                layer.close(index);
                clock();
            })
            clearInterval(int);
        }
    }
})